﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinCourseControls
{
    public partial class FrmToolStrip : Form
    {
        public FrmToolStrip()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 新增按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbtnAdd_Click(object sender, EventArgs e)
        {
            MForms.FrmAddGrade frmAdd = new MForms.FrmAddGrade(); // 实例化窗体
            frmAdd.MdiParent = this;  // 设置当前窗体的MDI父窗体
            frmAdd.Show(); // 显示窗体
        }

        /// <summary>
        /// 审核按钮 点击下拉按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtnCheck_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            tsbtnCheck.Text = e.ClickedItem.Text;//点击下拉项，文本就显示下拉项的文本
        }

        /// <summary>
        /// 点击审核按钮时发生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtnCheck_ButtonClick(object sender, EventArgs e)
        {
            MessageBox.Show("进行" + tsbtnCheck.Text + "功能！");
        }

    
        /// <summary>
        /// 图片-下拉项点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tddbtnState_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            MessageBox.Show(e.ClickedItem.Text + "功能！");  // 获取下拉项文本
        }

        /// <summary>
        /// 下拉列表项 属性值更改发生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tscboList_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show(tscboList.SelectedItem.ToString()); // 下拉列表选择项
        }

        /// <summary>
        /// 定时器用于控制进度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if(tsPbar.Value<tsPbar.Maximum)  // 进度值小于最大值
            {
                tsPbar.PerformStep();//向前走一步（增加Setp）
            }
            else
            {
                timer1.Stop(); // 进度条停止
            }
        }

        /// <summary>
        /// 页面加载-使用代码方式给工具栏对象容器添加控件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmToolStrip_Load(object sender, EventArgs e)
        {
            ToolStripSeparator sp = new ToolStripSeparator(); // 分隔条控件实例
            toolStrip1.Items.Add(sp); // 容器添加分隔条控件

            ToolStripButton btn = new ToolStripButton(); // 按钮控件实例
            btn.Text = "保存"; // 显示文本
            btn.Name = "tmiSave"; // 控件名称
            btn.Image = Image.FromFile("Resources/btnbg01.png"); // 绑定图片
            btn.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; // 设置显示内容
            btn.Click += Btn_Click; // 绑定点击事件
            toolStrip1.Items.Add(btn); // 容器添加按钮
        }

        /// <summary>
        /// 容器添加按钮-点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Click(object sender, EventArgs e)
        {
            MessageBox.Show("保存信息成功！");
        }
    }
}
